#include<stdio.h>
#pragma warning(disable:4996)
int gcd(int m, int n);
int main()
{
	int a=0, b=0;
	scanf("%d %d", a, b);
	int ret = gcd(a, b);
	printf("%d", ret);
	return 0;
}
int gcd(int m, int n)
{
	int mod;
	while (n)
	{
		mod = m % n;
		m = n;
		n = mod;
	}
	return n;
}